<?php
/**
 * Application model for Cake.
 *
 * This file is application-wide model file. You can put all
 * application-wide model-related methods here.
 *
 * PHP 5
 *
 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
 * Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 *
 * Licensed under The MIT License
 * Redistributions of files must retain the above copyright notice.
 *
 * @copyright     Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
 * @link          http://cakephp.org CakePHP(tm) Project
 * @package       app.Model
 * @since         CakePHP(tm) v 0.2.9
 * @license       MIT License (http://www.opensource.org/licenses/mit-license.php)
 */

App::uses('Model', 'Model');

/**
 * Application model for Cake.
 *
 * Add your application-wide methods in the class below, your models
 * will inherit them.
 *
 * @package       app.Model
 */
class AppModel extends Model {
	function replaceAlpha($string){
		$alpha = array(
				'A' => 'a', 
        'Á' => 'a',
        'À' => 'a',
        'Ả' => 'a',
        'Ã' => 'a',
        'Ạ' => 'a',
        'a' => 'a',
        'á' => 'a',
        'à' => 'a',
        'ả' => 'a',
        'ã' => 'a',
        'ạ' => 'a',
        'Ă' => 'a',
        'Ắ' => 'a',
        'Ằ' => 'a',
        'Ẳ' => 'a',
        'Ẵ' => 'a',
        'Ặ' => 'a',
        'ă' => 'a',
        'ắ' => 'a',
        'ằ' => 'a',
        'ẳ' => 'a',
        'ẵ' => 'a',
        'ặ' => 'a',
        'Â' => 'a',
        'Ấ' => 'a',
        'Ầ' => 'a',
        'Ẩ' => 'a',
        'Ẫ' => 'a',
        'Ậ' => 'a',
        'â' => 'a',
        'ấ' => 'a',
        'ầ' => 'a',
        'ẩ' => 'a',
        'ẫ' => 'a',
        'ậ' => 'a',
        'Đ' => 'd', 
        'đ' => 'd',
        'E' => 'e', 
        'É' => 'e',
        'È' => 'e',
        'Ẻ' => 'e',
        'Ẽ' => 'e',
        'Ẹ' => 'e',
        'e' => 'e',
        'é' => 'e',
        'è' => 'e',
        'ẻ' => 'e',
        'ẽ' => 'e',
        'ẹ' => 'e',
        'Ê' => 'e',
        'Ế' => 'e',
        'Ề' => 'e',
        'Ể' => 'e',
        'Ễ' => 'e',
        'Ệ' => 'e',
        'ê' => 'e',
        'ế' => 'e',
        'ề' => 'e',
        'ể' => 'e',
        'ễ' => 'e',
        'ệ' => 'e',
        'I' => 'i',
        'Í' => 'i',
        'Ì' => 'i',
        'Ỉ' => 'i',
        'Ĩ' => 'i',
        'Ị' => 'i',
        'i' => 'i',
        'í' => 'i',
        'ì' => 'i',
        'ỉ' => 'i',
        'ĩ' => 'i',
        'ị' => 'i',
        'O' => 'o',
        'ó' => 'o',
        'ò' => 'o',
        'ỏ' => 'o',
        'õ' => 'o',
        'ọ' => 'o',
        'O' => 'o',
        'Ó' => 'o',
        'Ò' => 'o',
        'Ỏ' => 'o',
        'Õ' => 'o',
        'Ọ' => 'o',
        'ô' => 'o',
        'ố' => 'o',
        'ồ' => 'o',
        'ổ' => 'o',
        'ỗ' => 'o',
        'ộ' => 'o',
        'Ô' => 'o',
        'Ố' => 'o',
        'Ồ' => 'o',
        'Ổ' => 'o',
        'Ỗ' => 'o',
        'Ộ' => 'o',
        'ơ' => 'o',
        'ớ' => 'o',
        'ờ' => 'o',
        'ở' => 'o',
        'ỡ' => 'o',
        'ợ' => 'o',
        'Ơ' => 'o',
        'Ớ' => 'o',
        'Ờ' => 'o',
        'Ở' => 'o',
        'Ỡ' => 'o',
        'Ợ' => 'o',
        'u' => 'u',
        'ú' => 'u',
        'ù' => 'u',
        'ủ' => 'u',
        'ũ' => 'u',
        'ụ' => 'u',
        'U' => 'u',
        'Ú' => 'u',
        'Ù' => 'u',
        'Ủ' => 'u',
        'Ũ' => 'u',
        'Ụ' => 'u',
        'ư' => 'u',
        'ứ' => 'u',
        'ừ' => 'u',
        'ử' => 'u',
        'ữ' => 'u',
        'ự' => 'u',
        'Ư' => 'u',
        'Ứ' => 'u',
        'Ừ' => 'u',
        'Ử' => 'u',
        'Ữ' => 'u',
        'Ự' => 'u',
        'y' => 'y',
        'ý' => 'y',
        'ỳ' => 'y',
        'ỷ' => 'y',
        'ỹ' => 'y',
        'ỵ' => 'y',
        'Y' => 'y',
        'Ý' => 'y',
        'Ỳ' => 'y',
        'Ỷ' => 'y',
        'Ỹ' => 'y',
        'Ỵ' => 'y');
			foreach($alpha as $key => $value){
				$string = str_replace($key, $value, $string);
			}
			return $string;			
	}
}
